package cn.epsilon3.service.thirdAuthLogin.impl;

import cn.epsilon3.common.Result;
import cn.epsilon3.domain.e3.dto.ThirdAuthLoginDTO;
import cn.epsilon3.utils.RetryUtils;
import cn.epsilon3.service.thirdAuthLogin.E3ThirdAuthLoginService;
import cn.epsilon3.service.thirdAuthLogin.E3ThirdAuthReqService;
import cn.epsilon3.service.user.E3UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 三方登录 OAuth2 实现
 *
 * @author: epsilon3
 * @date: 2023/10/22 21:17
 */
@Service
public class E3ThirdAuthLoginServiceImpl implements E3ThirdAuthLoginService {


    @Resource
    E3ThirdAuthReqService thirdAuthReqService;

    @Resource
    private E3UserService userService;

    @Override
    public Result<Object> to(ThirdAuthLoginDTO aliThirdAuthLoginDTO) {
        return userService.thirdAuthLogin(
                RetryUtils.start(5, 10, () -> thirdAuthReqService.to(aliThirdAuthLoginDTO)));
    }
}
